package com.dlz.systemshop.controller;

import com.dlz.systemshop.service.MailService;
import com.dlz.systemshop.utils.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 董熠涛
 * @date 2025/4/27 13:55
 */
@RestController
public class MailController {
    @Autowired
    private MailService mailService;

    ApiResponse<Boolean> apiResponse = new ApiResponse<Boolean>();


    @PostMapping("/sendMail")
    public ApiResponse<Boolean> sendMail(@RequestParam String to, @RequestParam String subject, @RequestParam String content) {
        boolean result = mailService.sendSimpleMail(to, subject, content);

        if (result) {
            apiResponse.oK("发送成功",result);
            return apiResponse;
        }
        apiResponse.error(500,"发送失败",result);
        return apiResponse;
    }
}
